package LC;

import java.util.Stack;

/**
 * @ClassName LC739
 * @Description: TODO
 * @Author hl
 * @Date 2020/9/12
 * @Version V1.0
 **/
public class LC739 {
    public int[] dailyTemperatures(int[] T) {
        if(T==null||T.length==0){
            return  null;
        }
        int []res=new int[T.length];
        Stack<Integer> stack=new Stack<>();
        for(int i=0;i<res.length;i++){
            while(!stack.isEmpty()&&T[stack.peek()]<T[i]){
                int key=stack.pop();
                res[key]=i-key;
            }
            stack.push(i);
        }
        return  res;
    }
}
